package com.woniuxy.springboot08rabbitmq.topic;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.sound.midi.Soundbank;

@Component
public class TopicCustomer {
    @RabbitListener(bindings = {
            @QueueBinding(value = @Queue,
                    exchange = @Exchange(value = "x1", type = "topic"), key = {"*.orange.*"})
    })
    public void receiveMSG1(String msg) {
        System.out.println("Topic消费方1：" + msg);
    }

    @RabbitListener(bindings = {
            @QueueBinding(value = @Queue,
                    exchange = @Exchange(value = "x1", type = "topic"), key = {"*.orange"})
    })
    public void receiveMSG2(String msg) {
        System.out.println("Topic消费方2：" + msg);
    }

    @RabbitListener(bindings = {
            @QueueBinding(value = @Queue,
                    exchange = @Exchange(value = "x1", type = "topic"), key = {"*.orange.#"})
    })
    public void receiveMSG3(String msg) {
        System.out.println("Topic消费方3：" + msg);
    }
}
